{% extends "zerver/portico.html" %}
{% set entrypoint = "dev-login" %}

{# Login page. #}
{% block portico_content %}
<!-- The following empty tag has unique data-page-id so that this
page can be easily identified in it's respective JavaScript file -->
<div data-page-id="dev-login"></div>
<div class="app login-page flex full-page">
    <div class="app-main login-page-container dev-login white-box">
        {% if current_realm %}
        <h4 class="login-page-header">Click on a user to log in to {{ current_realm.name }}!</h4>
        {% else %}
        <h4 class="login-page-header">Click on a user to log in!</h4>
        {% endif %}
        <p class="devlogin_subheader">(Or visit the <a href="/login/">normal login page</a>.)</p>
        <form name="direct_login_form" id="direct_login_form" method="post" class="login-form">
            <input type="hidden" name="next" value="{{ next }}" />
            <div class="control-group">
                <div class="controls">
                    <div class="group">
                        <h2>{{_('Owners') }}</h2>
                        {% if direct_owners %}
                            {% for direct_owner in direct_owners %}
                            <p><input type="submit" formaction="{{ direct_owner.realm.uri }}{{ url('login-local') }}"
                                      name="direct_email" class="btn-direct btn-admin" value="{{ direct_owner.delivery_email }}" /></p>
                            {% endfor %}
                        {% else %}
                            <p>No owners found in this realm</p>
                        {% endif %}
                        <h2>{{ _('Administrators') }}</h2>
                        {% if direct_admins %}
                            {% for direct_admin in direct_admins %}
                            <p><input type="submit" formaction="{{ direct_admin.realm.uri }}{{ url('login-local') }}"
                                      name="direct_email" class="btn-direct btn-admin" value="{{ direct_admin.delivery_email }}" /></p>
                            {% endfor %}
                        {% else %}
                            <p>No administrators found in this realm</p>
                        {% endif %}
                        <h2>{{ _('Guest users') }}</h2>
                        {% if guest_users %}
                            {% for guest_user in guest_users %}
                            <p><input type="submit" formaction="{{ guest_user.realm.uri }}{{ url('login-local') }}"
                                      name="direct_email" class="btn-direct btn-admin" value="{{ guest_user.delivery_email }}" /></p>
                            {% endfor %}
                        {% else %}
                            <p>No guest users found in this realm</p>
                        {% endif %}
                    </div>

                    <div class="group">
                        <h2>{{ _('Normal users') }}</h2>
                        {% if direct_users %}
                            {% for direct_user in direct_users %}
                            <p><input type="submit" formaction="{{ direct_user.realm.uri }}{{ url('login-local') }}"
                                      name="direct_email" class="btn-direct btn-admin" value="{{ direct_user.delivery_email }}" /></p>
                            {% endfor %}
                        {% else %}
                            <p>No normal users found in this realm</p>
                        {% endif %}
                    </div>
                </div>
            </div>
        </form>
        <form name="change_realm" action="{{ url('login_page') }}" method="post">
            {{ csrf_input }}
            <h2>Realm</h2>
            <select name="new_realm" onchange="this.form.submit()">
                <option value="all_realms" {% if not current_realm %}selected="selected"{% endif %}>All Realms</option>
                {% for realm in all_realms %}
                <option value="{{realm.string_id}}" {% if current_realm == realm %}selected="selected"{% endif %}>{{realm.name}}</option>
                {% endfor %}
            </select>
        </form>
        <div id="devtools-wrapper">
            <div id="devtools-registration">
                <form name="register_dev_user" action="{{ url('register_dev_user') }}" method="POST">
                    <input type="submit" class="btn btn-admin" value="Create New User" />
                </form>
                <form name="register_dev_realm" action="{{ url('register_dev_realm') }}" method="POST">
                    <input type="submit" class="btn btn-admin" value="Create New Realm" />
                </form>
            </div>
            <a href="/devtools">Zulip developer tools</a>
        </div>
    </div>
</div>

{% endblock %}
